Get the invalidated region from ScrollWindowEx() instead of an incorrect
authorTor Lillqvist <tml@novell.com>
Mon, 2 Jan 2006 00:45:39 +0000 (00:45 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Mon, 2 Jan 2006 00:45:39 +0000 (00:45 +0000)
2006-01-02  Tor Lillqvist  <tml@novell.com>

* gdk/win32/gdkgeometry-win32.c (gdk_window_scroll): Get the
invalidated region from ScrollWindowEx() instead of an incorrect
attempt to calculate it ourselves. Fix by John Ehresman. (#323666)

* gdkevents-win32.c: Make _gdk_win32_hrgn_to_region() non-static.

* gdkprivate-win32.h: Declare it.

ChangeLog
ChangeLog.pre-2-10
gdk/win32/gdkevents-win32.c
gdk/win32/gdkgeometry-win32.c
gdk/win32/gdkprivate-win32.h

index 813653cfdf6fe0da5579797ab8c921aa35e6c5e4..f83d8d76251ecc150f104bc18970027b466f1be7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2006-01-02  Tor Lillqvist  <tml@novell.com>
+
+       * gdk/win32/gdkgeometry-win32.c (gdk_window_scroll): Get the
+       invalidated region from ScrollWindowEx() instead of an incorrect
+       attempt to calculate it ourselves. Fix by John Ehresman. (#323666)
+
+       * gdkevents-win32.c: Make _gdk_win32_hrgn_to_region() non-static.
+
+       * gdkprivate-win32.h: Declare it.
+
 2005-12-31  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkaction.c: 
index 813653cfdf6fe0da5579797ab8c921aa35e6c5e4..f83d8d76251ecc150f104bc18970027b466f1be7 100644 (file)
@@ -1,3 +1,13 @@
+2006-01-02  Tor Lillqvist  <tml@novell.com>
+
+       * gdk/win32/gdkgeometry-win32.c (gdk_window_scroll): Get the
+       invalidated region from ScrollWindowEx() instead of an incorrect
+       attempt to calculate it ourselves. Fix by John Ehresman. (#323666)
+
+       * gdkevents-win32.c: Make _gdk_win32_hrgn_to_region() non-static.
+
+       * gdkprivate-win32.h: Declare it.
+
 2005-12-31  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkaction.c: 
index 58777b7a0f86729de901181a08b28c2d40ca6bac..6252776d4eaf17b1086604c2e942d3cca59c8586 100644 (file)
@@ -1973,7 +1973,7 @@ erase_background (GdkWindow *window,
     }
 }
 
-static GdkRegion *
+GdkRegion *
 _gdk_win32_hrgn_to_region (HRGN hrgn)
 {
   RGNDATA *rgndata;
@@ -3069,6 +3069,43 @@ gdk_event_translate (MSG  *msg,
       KillTimer (NULL, resize_timer);
       break;
 
+#ifdef G_ENABLE_DEBUG
+    case WM_NCCALCSIZE:
+      if (msg->wParam)
+       {
+         NCCALCSIZE_PARAMS *nccsp = (NCCALCSIZE_PARAMS *) msg->lParam;
+         GDK_NOTE (EVENTS, g_print (" TRUE %s %s %s %s",
+                                    _gdk_win32_rect_to_string (&nccsp->rgrc[0]),
+                                    _gdk_win32_rect_to_string (&nccsp->rgrc[1]),
+                                    _gdk_win32_rect_to_string (&nccsp->rgrc[2]),
+                                    _gdk_win32_windowpos_to_string (nccsp->lppos)));
+       }
+      else
+       GDK_NOTE (EVENTS, g_print (" FALSE %s",
+                                  _gdk_win32_rect_to_string ((RECT *) msg->lParam)));
+      return_val = TRUE;
+      GDK_NOTE (EVENTS, g_print (" DefWindowProc"));
+      *ret_valp = DefWindowProc (msg->hwnd, msg->message, msg->wParam, msg->lParam);
+      if (msg->wParam)
+       {
+         NCCALCSIZE_PARAMS *nccsp = (NCCALCSIZE_PARAMS *) msg->lParam;
+         GDK_NOTE (EVENTS,
+                   (g_print ("%s%s%s%s%s%s%s",
+                             (*ret_valp & WVR_ALIGNTOP) ? "ALIGNTOP " : "",
+                             (*ret_valp & WVR_ALIGNLEFT) ? "ALIGNLEFT " : "",
+                             (*ret_valp & WVR_ALIGNBOTTOM) ? "ALIGNBOTTOM " : "",
+                             (*ret_valp & WVR_ALIGNRIGHT) ? "ALIGNRIGHT " : "",
+                             (*ret_valp & WVR_HREDRAW) ? "HREDRAW " : "",
+                             (*ret_valp & WVR_VREDRAW) ? "VREDRAW " : "",
+                             (*ret_valp & WVR_VALIDRECTS) ? "VALIDRECTS " : ""),
+                    ((*ret_valp & WVR_VALIDRECTS) ?
+                     g_print (" %s %s",
+                              _gdk_win32_rect_to_string (&nccsp->rgrc[1]),
+                              _gdk_win32_rect_to_string (&nccsp->rgrc[2])) : 0)));
+       }
+      break;
+#endif
+
     case WM_WINDOWPOSCHANGED :
       /* Once we've entered the moving or sizing modal loop, we won't
        * return to the main loop until we're done sizing or moving.
@@ -3283,7 +3320,9 @@ gdk_event_translate (MSG  *msg,
          rect.right = impl->hints.min_width;
          rect.bottom = impl->hints.min_height;
 
+         GDK_NOTE (EVENTS, g_print (" (have MIN_SIZE: %dx%d)", impl->hints.min_width, impl->hints.min_height));
          _gdk_win32_adjust_client_rect (window, &rect);
+         GDK_NOTE (EVENTS, g_print (" (after AdjustWindowRectEx: %dx%d)", rect.right - rect.left, rect.bottom - rect.top));
 
          mmi->ptMinTrackSize.x = rect.right - rect.left;
          mmi->ptMinTrackSize.y = rect.bottom - rect.top;
@@ -3297,7 +3336,9 @@ gdk_event_translate (MSG  *msg,
          rect.right = impl->hints.max_width;
          rect.bottom = impl->hints.max_height;
 
+         GDK_NOTE (EVENTS, g_print (" (have MAX_SIZE: %dx%d)", impl->hints.max_width, impl->hints.max_height));
          _gdk_win32_adjust_client_rect (window, &rect);
+         GDK_NOTE (EVENTS, g_print (" (after AdjustWindowRectEx: %dx%d)", rect.right - rect.left, rect.bottom - rect.top));
 
          /* at least on win9x we have the 16 bit trouble */
          maxw = rect.right - rect.left;
index 5c5b51be813dc7ab022eef58d93c6c1aa88c7082..95056a701592ce93bb1954ea1802613992a0dbcd 100644 (file)
@@ -108,9 +108,9 @@ gdk_window_scroll (GdkWindow *window,
   GdkRegion *invalidate_region;
   GdkWindowImplWin32 *impl;
   GdkWindowObject *obj;
-  GdkRectangle dest_rect;
   GList *tmp_list;
   GdkWindowParentPos parent_pos;
+  HRGN native_invalidate_region;
   
   g_return_if_fail (GDK_IS_WINDOW (window));
 
@@ -130,22 +130,6 @@ gdk_window_scroll (GdkWindow *window,
   if (obj->update_area)
     gdk_region_offset (obj->update_area, dx, dy);
   
-  invalidate_region = gdk_region_rectangle (&impl->position_info.clip_rect);
-  
-  dest_rect = impl->position_info.clip_rect;
-  dest_rect.x += dx;
-  dest_rect.y += dy;
-  gdk_rectangle_intersect (&dest_rect, &impl->position_info.clip_rect, &dest_rect);
-
-  if (dest_rect.width > 0 && dest_rect.height > 0)
-    {
-      GdkRegion *tmp_region;
-
-      tmp_region = gdk_region_rectangle (&dest_rect);
-      gdk_region_subtract (invalidate_region, tmp_region);
-      gdk_region_destroy (tmp_region);
-    }
-  
   gdk_window_compute_parent_pos (impl, &parent_pos);
 
   parent_pos.x += obj->x;
@@ -156,10 +140,13 @@ gdk_window_scroll (GdkWindow *window,
 
   gdk_window_tmp_unset_bg (window);
 
-  if (!ScrollWindowEx (GDK_WINDOW_HWND (window),
-                      dx, dy, NULL, NULL,
-                      NULL, NULL, SW_SCROLLCHILDREN))
-    WIN32_API_FAILED ("ScrollWindowEx");
+  native_invalidate_region = CreateRectRgn (0, 0, 0, 0);
+  if (native_invalidate_region == NULL)
+    WIN32_API_FAILED ("CreateRectRgn");
+
+  API_CALL (ScrollWindowEx, (GDK_WINDOW_HWND (window),
+                            dx, dy, NULL, NULL,
+                            native_invalidate_region, NULL, SW_SCROLLCHILDREN));
 
   if (impl->position_info.no_bg)
     gdk_window_tmp_reset_bg (window);
@@ -173,8 +160,15 @@ gdk_window_scroll (GdkWindow *window,
       tmp_list = tmp_list->next;
     }
 
-  gdk_window_invalidate_region (window, invalidate_region, TRUE);
-  gdk_region_destroy (invalidate_region);
+  if (native_invalidate_region != NULL)
+    {
+      invalidate_region = _gdk_win32_hrgn_to_region (native_invalidate_region);
+      gdk_region_offset (invalidate_region, impl->position_info.x_offset,
+                         impl->position_info.y_offset);
+      gdk_window_invalidate_region (window, invalidate_region, TRUE);
+      gdk_region_destroy (invalidate_region);
+      GDI_CALL (DeleteObject, (native_invalidate_region));
+    }
 }
 
 void
index 0489dd36cbc5feacf54e0a5dbf6fc70c5bf4339c..1ff541c8f07748af92e06380155ff180a31107d6 100644 (file)
@@ -353,6 +353,8 @@ HRGN          _gdk_win32_gdkregion_to_hrgn  (GdkRegion   *region,
                                         gint         x_origin,
                                         gint         y_origin);
 
+GdkRegion *_gdk_win32_hrgn_to_region    (HRGN hrgn);
+
 void   _gdk_win32_adjust_client_rect   (GdkWindow *window,
                                         RECT      *RECT);